<template>
  <div>
     <input type="text" class="form-control" 
     placeholder="请输入今天的任务清单，按回车建确认" v-model="task" @keydown.enter="addItem">
  </div>
</template>

<script>
export default {
  props: {
    addTodo: Function,
    todos: Array
  },
  data() {
    return {
      task: ''
    }
  },
  setup () {
    return {}
  },
  methods: {
    addItem() {
      if(this.task) {
        this.addTodo({
          id: this.todos.length,
          title: this.task,
          finish: false
        })
      }
      this.task = ''
    }
  },
}
</script>

<style lang="scss" scoped>

</style>